package com.etc.my.service.impl;


import com.etc.my.dao.ReserveDao;
import com.etc.my.dto.CountDto;
import com.etc.my.dto.ReserveAndCarMessageDto;
import com.etc.my.dto.ReserveDto;
import com.etc.my.entity.Reserve;
import com.etc.my.service.ReserveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ReserveServiceImpl implements ReserveService {
    @Autowired
    private ReserveDao dao;

    public ReserveDao getDao() {
        return dao;
    }

    public void setDao(ReserveDao dao) {
        this.dao = dao;
    }


    @Override
    public List<ReserveAndCarMessageDto> getReserveByUserId(Integer userId, Integer page, Integer size) {
        return dao.queryReserveByUserId(userId, page, size);
    }

    @Override
    public CountDto getReserveCountByUserId(Integer userId) {
        return dao.queryReserveCountByUserId(userId);
    }

    @Override
    public boolean addReserveMsg(ReserveDto reserveDto) {
        if (reserveDto.getReserve_phone()!=null&&reserveDto.getReserve_date()!=null){
            return dao.addReserveMsg(reserveDto);
        }
        return false;
    }

    @Override
    public boolean deleteReserveMsg(Integer reserve_id) {
        if(reserve_id==null || reserve_id<0){
            return false;
        }else{
            return dao.cancelReserveMsg(reserve_id);
        }

    }
}
